<?php
session_start();
//require_once("../config/include.inc.php");
require_once("../config/include_tokyo.inc.php");
require_once("../class/Core_Lib_Page.php");
require_once("../class/Common_Function.php");

$commonFunction = new Common_Function();

//访问权限验证
$userRole = $_SESSION['user_role'];
$current_system = $_SESSION['current_system'];
if($userRole == 1 || $userRole == 4 || $userRole == 5 || $userRole == 8){
	//管理员,订单管理员,任务管理员+订单管理员
}else{
	if($userRole > 0){
		$url = "../index.php?loginError=2";//没权限
	}else{
		$url = "../index.php?loginError=3";//没登录
	}	
	echo "<script language='javascript' type='text/javascript'>";
	echo "window.location.href='$url'";
	echo "</script>";
}


//获取form值
$doFlag = $_POST["doFlag"];
$_POST["sendEmailFlag"] = '';
if($doFlag == "addProcess"){
	//订单进展
	$orderId = $_POST["orderId"];
	$processStr = $_POST["process_".$orderId];
	$sql = "insert into orderprocess(order_id,order_process) values ($orderId,'$processStr')";
	$db->Execute($sql);
}else if($doFlag == "updateBatteryFlag"){
	//更改电池状态
	$orderId = $_POST["orderId"];
	$battery_flag = $_POST["battery_flag_".$orderId];
	$processStr = "电池:无电池";
	if($battery_flag == "1"){
		$processStr = "电池:有电池";
	}
	$sql = "insert into orderprocess(order_id,order_process) values ($orderId,'$processStr')";
	$db->Execute($sql);	
	$sql = "update orders set battery_flag = ".$battery_flag." where id=".$orderId;
	$db->Execute($sql);	
	$_POST["doFlag"] = "addProcess"; //光标定位
}else if($doFlag == "updateDeliverFlag"){
	//更改快递状态
	$orderId = $_POST["orderId"];
	$deliver_flag = $_POST["deliver_flag_".$orderId];
	$processStr = "快递:";
	$processStr = $processStr.$commonFunction->getDeliverName($deliver_flag);
	$sql = "insert into orderprocess(order_id,order_process) values ($orderId,'$processStr')";
	$db->Execute($sql);	
	$sql = "update orders set deliver_flag = ".$deliver_flag." where id=".$orderId;
	$db->Execute($sql);	
	$_POST["doFlag"] = "addProcess"; //光标定位
}else if($doFlag == "updateProductDescription"){
	//更改订单产品描述
	$orderId = $_POST["orderId"];
	$product_description = $_POST["product_description_".$orderId];
	$sql = "update orders set product_description = '".$product_description."' where id=".$orderId;
	$db->Execute($sql);	
	$_POST["doFlag"] = "addProcess"; //光标定位
}else if($doFlag == "paymentEmail"){
	// 邮件: 付款方式
	$orderId = $_POST["orderId"];
	$processStr = "邮件: 付款方式";
	$sql = "insert into orderprocess(order_id,order_process) values ($orderId,'$processStr')";
	$db->Execute($sql);		
	$_POST["doFlag"] = "addProcess"; //光标定位	
	$_POST["sendEmailFlag"] = "paymentEmail";
}else if($doFlag == "askPaymentEmail"){
	// 邮件:催付款
	$orderId = $_POST["orderId"];
	$processStr = "邮件: 催付款";
	$sql = "insert into orderprocess(order_id,order_process) values ($orderId,'$processStr')";
	$db->Execute($sql);	
	$_POST["doFlag"] = "addProcess"; //光标定位	
	$_POST["sendEmailFlag"] = "askPaymentEmail";	
}else if($doFlag == "confirmPaymentEmail"){
	// 邮件:确认付款
	$orderId = $_POST["orderId"];
	$sql = "update orders set order_status = 20,pay_time=now() where id=".$orderId;//订单状态:已付款
	$db->Execute($sql);
	$processStr = "邮件: 确认付款";
	$sql = "insert into orderprocess(order_id,order_process) values ($orderId,'$processStr')";
	$db->Execute($sql);	
	$_POST["doFlag"] = "addProcess"; //光标定位	
	$_POST["sendEmailFlag"] = "confirmPaymentEmail";	
}else if($doFlag == "sendPackage"){
	// 状态更新:已发货(等快递单)	
	$orderId = $_POST["orderId"];
	$orderSite = $_POST["orderSite"];
	$orderSite = strtolower($orderSite);
	//$sql = "update orders set order_status = 30,deliver_flag = 1,deliver_time=now()  where id=".$orderId;//订单状态:已发货
	$sql = "update orders set order_status = 30,deliver_flag = 4,deliver_time=now()  where id=".$orderId;//订单状态:已发货+快递默认：eub
	
	$db->Execute($sql);
	$processStr = "已发货,等快递单";
	$sql = "insert into orderprocess(order_id,order_process) values ($orderId,'$processStr')";
	$db->Execute($sql);	
	$_POST["doFlag"] = "addProcess"; //光标定位		
}else if($doFlag == "doTracking"){
	// 转入跟单
	$orderId = $_POST["orderId"];
	$sql = "update orders set tracking_flag = 1 where id=".$orderId;
	$db->Execute($sql);
	$processStr = "转入跟单";
	$sql = "insert into orderprocess(order_id,order_process) values ($orderId,'$processStr')";
	$db->Execute($sql);	
	$_POST["doFlag"] = "addProcess"; //光标定位		
}else if($doFlag == "doCancel"){
	// 状态更新:取消订单
	$orderId = $_POST["orderId"];
	$sql = "update orders set order_status = 100,deliver_flag = 0 where id=".$orderId;//订单状态:已取消,快递状态：不需要快递
	$db->Execute($sql);
	$processStr = "取消订单";
	$sql = "insert into orderprocess(order_id,order_process) values ($orderId,'$processStr')";
	$db->Execute($sql);	
}else if($doFlag == "sendTrackingNumber"){
	//发快递单给客户
	//订单状态改成40"已完成";
	//快递状态改成2"已发邮件给客户"-->修改：e邮宝的件 要改成6
	//进展中插入"完成,已发快递单给客户"
	//生产邮件内容(在后面完成js中)
	$orderId = $_POST["orderId"];
	$deliverFlag = $_POST["deliverFlag"];
	if($deliverFlag == 10){//10=走飞翔,已有单号;
		$sql = "update orders set order_status = 40,deliver_flag=2 where id=".$orderId;
	}else if($deliverFlag == 5){//5=走e邮宝,已有单号;
		$sql = "update orders set order_status = 40,deliver_flag=6 where id=".$orderId;
	}else if($deliverFlag == 8){//8=走易运,已有单号;
		$sql = "update orders set order_status = 40,deliver_flag=9 where id=".$orderId;
	}else if($deliverFlag == 12){//12=走阿运,已有单号;
		$sql = "update orders set order_status = 40,deliver_flag=13 where id=".$orderId;
	}else{
		$sql = "update orders set order_status = 40 where id=".$orderId;
		echo "**********************快递单号状态异常,还没填单号,就直接改成发快单号给客户****************************************";
	}
	$db->Execute($sql);
	$processStr = "订单完成,已发快递单给客户";
	$sql = "insert into orderprocess(order_id,order_process) values ($orderId,'$processStr')";
	$db->Execute($sql);	
	$_POST["doFlag"] = "addProcess"; //光标定位	
	$_POST["sendEmailFlag"] = "sendTrackingNumber";
}else if($doFlag == "emptyEmail"){
	//生成空内容邮件
	//生产邮件内容(在后面完成js中)
	$_POST["doFlag"] = "addProcess"; //光标定位	
	$_POST["sendEmailFlag"] = "emptyEmail";
}else if($doFlag == "doInStock"){
	//快递状态修改：货到了->需要快递
	$orderId = $_POST["orderId"];
	//$sql = "update orders set deliver_flag = 1 where id=".$orderId;
	$sql = "update orders set deliver_flag = 4 where id=".$orderId; //default:eub
	$db->Execute($sql);
	$processStr = "状态: 货到了";
	$sql = "insert into orderprocess(order_id,order_process) values ($orderId,'$processStr')";
	$db->Execute($sql);	
	$_POST["doFlag"] = "addProcess"; //光标定位	
}else if($doFlag == "doOutStock"){
	//快递状态修改：缺货登记->不需要快递
	$orderId = $_POST["orderId"];
	$sql = "update orders set deliver_flag = 0 where id=".$orderId;
	$db->Execute($sql);
	$processStr = "状态: 缺货登记";
	$sql = "insert into orderprocess(order_id,order_process) values ($orderId,'$processStr')";
	$db->Execute($sql);	
	$_POST["doFlag"] = "addProcess"; //光标定位	
}else if($doFlag == "beginCustomerService"){
	//转售后
	$orderId = $_POST["orderId"];
	$sql = "update orders set customer_service_flag = 1 where order_status=40 and id=".$orderId;
	$db->Execute($sql);
	$processStr = "转入售后";
	$sql = "insert into orderprocess(order_id,order_process) values ($orderId,'$processStr')";
	$db->Execute($sql);	
	//转到 售后处理列表
	$doFlag = "toOrderStatus";
	$_POST["currentOrderStatus"] = "200"; 
	$_POST["doFlag"] = "addProcess"; //光标定位	
}else if($doFlag == "endCustomerService"){
	//售后完成
	$orderId = $_POST["orderId"];
	$sql = "update orders set customer_service_flag = 2 where order_status=40 and id=".$orderId;
	$db->Execute($sql);
	$processStr = "售后完成";
	$sql = "insert into orderprocess(order_id,order_process) values ($orderId,'$processStr')";
	$db->Execute($sql);	
	//转到 全部售后列表
	$doFlag = "toOrderStatus";
	$_POST["currentOrderStatus"] = "300";
	$_POST["doFlag"] = "addProcess"; //光标定位	
}
//end if doFlag


//分页设置
$list_rows = 50; //每页显示的记录数
$sql_list = "SELECT COUNT(*) as total_rows  from orders o where (o.order_status = 10 or o.order_status = 20 or o.order_status = 30)   "; //处理中
$orderStatus = $_POST["orderStatus"];
$orderStatus_0 = "";
$orderStatus_1 = "";
$orderStatus_10 = "";
$orderStatus_20 = "";
$orderStatus_30 = "";
$orderStatus_40 = "";
$orderStatus_100 = "";
if($orderStatus == "0"){
	$orderStatus_0 = "selected";
}else if($orderStatus == "1"){
	$orderStatus_1 = "selected";
}else if($orderStatus == "10"){
	$orderStatus_10 = "selected";
}else if($orderStatus == "20"){
	$orderStatus_20 = "selected";
}else if($orderStatus == "30"){
	$orderStatus_30 = "selected";
}else if($orderStatus == "40"){
	$orderStatus_40 = "selected";
}else if($orderStatus == "100"){
	$orderStatus_100 = "selected";
}else{
	$orderStatus_0 = "selected";
}
$searchValue = $_POST["search-value"];

$searchValue = trim($searchValue);
if($doFlag == "doSearch"){	
	if($searchValue == ""){
		if($orderStatus == "0"){
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o";
		}else if($orderStatus == "1"){
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o where (order_status = 10 or order_status = 20 or order_status = 30)";
		}else if($orderStatus == "10"){
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o where order_status = 10 ";
		}else if($orderStatus == "20"){
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o where order_status = 20 ";
		}else if($orderStatus == "30"){
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o where order_status = 30 ";
		}else if($orderStatus == "40"){
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o where order_status = 40 ";
		}else if($orderStatus == "100"){
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o where order_status = 100 ";
		}else{
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o";
		}		
	}else{
		if($orderStatus == "0"){
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o where  (order_no like '%".$searchValue."%' or customer_name like '%".$searchValue."%' or customer_email like '%".$searchValue."%')";
		}else if($orderStatus == "1"){
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o where (order_status = 10 or order_status = 20 or order_status = 30) and (order_no like '%".$searchValue."%' or customer_name like '%".$searchValue."%' or customer_email like '%".$searchValue."%')";
		}else if($orderStatus == "10"){
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o where order_status = 10 and (order_no like '%".$searchValue."%' or customer_name like '%".$searchValue."%' or customer_email like '%".$searchValue."%')";
		}else if($orderStatus == "20"){
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o where order_status = 20 and (order_no like '%".$searchValue."%' or customer_name like '%".$searchValue."%' or customer_email like '%".$searchValue."%')";
		}else if($orderStatus == "30"){
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o where order_status = 30 and (order_no like '%".$searchValue."%' or customer_name like '%".$searchValue."%' or customer_email like '%".$searchValue."%')";
		}else if($orderStatus == "40"){
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o where order_status = 40 and (order_no like '%".$searchValue."%' or customer_name like '%".$searchValue."%' or customer_email like '%".$searchValue."%')";
		}else if($orderStatus == "100"){
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o where order_status = 100 and (order_no like '%".$searchValue."%' or customer_name like '%".$searchValue."%' or customer_email like '%".$searchValue."%')";
		}else{
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o (order_no like '%".$searchValue."%' or customer_name like '%".$searchValue."%' or customer_email like '%".$searchValue."%')";
		}		
	}	
}else if($doFlag == "toOrderStatus"){
		$orderStatus = $_POST["currentOrderStatus"];
		if($orderStatus == "0"){
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o";
		}else if($orderStatus == "10"){
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o where order_status = 10 ";
		}else if($orderStatus == "20"){
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o where order_status = 20 ";
		}else if($orderStatus == "30"){
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o where order_status = 30 ";
		}else if($orderStatus == "40"){
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o where order_status = 40 ";
		}else if($orderStatus == "100"){
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o where order_status = 100 ";
		}else if($orderStatus == "200"){ //售后中
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o where order_status = 40 and customer_service_flag = 1";
		}else if($orderStatus == "300"){ //全部售后
			$sql_list = "SELECT COUNT(*) as total_rows  from orders o where order_status = 40 and (customer_service_flag = 1 or customer_service_flag = 2)";
		}
}
$result = $db->Execute($sql_list);
if (!empty($result)) {
	$totalRows = $result->fields['total_rows'];
}
$nowPage = $_POST['nowPage'];
$nowPage = !empty($nowPage) ? $nowPage : 1;
$params = array(
	'total_rows'=>$totalRows,
	'list_rows'=>$list_rows,
	'method'    =>'ajax',
	'ajax_func_name' =>'goToPage',
	'now_page' => $nowPage
);
$page = new Core_Lib_Page($params);
$limit_m = $page->first_row;
$limit_n = $list_rows;


//显示列表
$sql = "SELECT * from orders o where  (o.order_status = 10 or o.order_status = 20 or o.order_status = 30   ) order by modify_time desc limit $limit_m,$limit_n"; //default 处理中订单
if($doFlag == "doSearch"){
	if($searchValue == ""){
		if($orderStatus == "0"){
			$sql = "SELECT *  from orders o order by modify_time desc limit $limit_m,$limit_n"; 
		}else if($orderStatus == "1"){
			$sql = "SELECT *  from orders o where (order_status = 10 or order_status = 20 or order_status = 30) order by modify_time desc limit $limit_m,$limit_n"; 
		}else if($orderStatus == "10"){
			$sql = "SELECT *  from orders o where order_status = 10  order by modify_time desc limit $limit_m,$limit_n"; 
		}else if($orderStatus == "20"){
			$sql = "SELECT *  from orders o where order_status = 20 order by modify_time desc limit $limit_m,$limit_n"; 
		}else if($orderStatus == "30"){
			$sql = "SELECT *  from orders o where order_status = 30 order by modify_time desc limit $limit_m,$limit_n"; 
		}else if($orderStatus == "40"){
			$sql = "SELECT *  from orders o where order_status = 40 order by modify_time desc limit $limit_m,$limit_n"; 
		}else if($orderStatus == "100"){
			$sql = "SELECT *  from orders o where order_status = 100 order by modify_time desc limit $limit_m,$limit_n"; 
		}else{
			$sql = "SELECT *  from orders o order by modify_time desc limit $limit_m,$limit_n"; 
		}	
		
	}else{	
		if($orderStatus == "0"){
			$sql = "SELECT *  from orders o where  (order_no like '%".$searchValue."%' or customer_name like '%".$searchValue."%' or customer_email like '%".$searchValue."%') order by modify_time desc limit $limit_m,$limit_n"; 
		}else if($orderStatus == "1"){
			$sql = "SELECT *  from orders o where (order_status = 10 or order_status = 20 or order_status = 30) and (order_no like '%".$searchValue."%' or customer_name like '%".$searchValue."%' or customer_email like '%".$searchValue."%') order by modify_time desc limit $limit_m,$limit_n"; 
		}else if($orderStatus == "10"){
			$sql = "SELECT *  from orders o where order_status = 10 and (order_no like '%".$searchValue."%' or customer_name like '%".$searchValue."%' or customer_email like '%".$searchValue."%') order by modify_time desc limit $limit_m,$limit_n"; 
		}else if($orderStatus == "20"){
			$sql = "SELECT *  from orders o where order_status = 20 and (order_no like '%".$searchValue."%' or customer_name like '%".$searchValue."%' or customer_email like '%".$searchValue."%')  order by modify_time desc limit $limit_m,$limit_n"; 
		}else if($orderStatus == "30"){
			$sql = "SELECT *  from orders o where order_status = 30 and (order_no like '%".$searchValue."%' or customer_name like '%".$searchValue."%' or customer_email like '%".$searchValue."%') order by modify_time desc limit $limit_m,$limit_n"; 
		}else if($orderStatus == "40"){
			$sql = "SELECT *  from orders o where order_status = 40 and (order_no like '%".$searchValue."%' or customer_name like '%".$searchValue."%' or customer_email like '%".$searchValue."%') order by modify_time desc limit $limit_m,$limit_n"; 
		}else if($orderStatus == "100"){
			$sql = "SELECT *  from orders o where order_status = 100 and (order_no like '%".$searchValue."%' or customer_name like '%".$searchValue."%' or customer_email like '%".$searchValue."%') order by modify_time desc limit $limit_m,$limit_n"; 
		}else{
			$sql = "SELECT *  from orders o (order_no like '%".$searchValue."%' or customer_name like '%".$searchValue."%' or customer_email like '%".$searchValue."%') order by modify_time desc limit $limit_m,$limit_n"; 
		}		
		 
	}	
}else if($doFlag == "toOrderStatus"){
		$orderStatus = $_POST["currentOrderStatus"];
		if($orderStatus == "0"){
			$sql = "SELECT *  from orders o   order by modify_time desc limit $limit_m,$limit_n"; 
		}else if($orderStatus == "10"){
			$sql = "SELECT *  from orders o where order_status = 10  order by modify_time desc limit $limit_m,$limit_n"; 
		}else if($orderStatus == "20"){
			$sql = "SELECT *  from orders o where order_status = 20 order by modify_time desc limit $limit_m,$limit_n"; 
		}else if($orderStatus == "30"){
			$sql = "SELECT *  from orders o where order_status = 30 order by modify_time desc limit $limit_m,$limit_n"; 
		}else if($orderStatus == "40"){
			$sql = "SELECT *  from orders o where order_status = 40 order by modify_time desc limit $limit_m,$limit_n"; 
		}else if($orderStatus == "100"){
			$sql = "SELECT *  from orders o where order_status = 100 order by modify_time desc limit $limit_m,$limit_n"; 
		}else if($orderStatus == "200"){ //售后中
			$sql = "SELECT *  from orders o where order_status = 40 and customer_service_flag = 1 order by modify_time desc limit $limit_m,$limit_n"; 
		}else if($orderStatus == "300"){ //全部售后
			$sql = "SELECT *  from orders o where order_status = 40 and (customer_service_flag = 1 or customer_service_flag = 2) order by modify_time desc limit $limit_m,$limit_n"; 
		}
}

$result = $db->Execute($sql);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<!--Begin:head-->
<? $pageTitle = "订单列表"; ?>
<?php include("../head.php"); ?>
<!--End:head-->


<body>
<?php
$errorMsg = $_GET['errorMsg'];
if($errorMsg != ""){
	echo  "***************************************<br>没这个订单ID：".$errorMsg."<br>***************************************<br>";
}	
?>

<?php include("../topMenu.php"); ?>


<form name="listForm" action="../order/orderList.php" method="post">
<div id="container" >	

<div id="search" class="leftDiv topDiv-10">
订单状态:
<select name="orderStatus" id="orderStatus">
<option value=0  <?php echo $orderStatus_0; ?> >全部</option>
<option value=1  <?php echo $orderStatus_1; ?> >处理中</option>
<option value=10 <?php echo $orderStatus_10; ?> >没付款</option>
<option value=20 <?php echo $orderStatus_20; ?> >已付款</option>
<option value=30 <?php echo $orderStatus_30; ?> >已发货</option>
<option value=40 <?php echo $orderStatus_40; ?> >已完成</option>
<option value=100 <?php echo $orderStatus_100; ?> >已取消</option>
</select>
<br>
<input type="text" name="search-value" id="search-value" size="30" value="<?php echo $searchValue;?>"><br>
<input type="button" name="Search" value="搜 索" onclick="doSearch()">
</div>


<div id="addOrder" class="leftDiv left2" >
<?php if($userRole >0 ){?>
<table>


<tr>
<td><a href="http://www.lucklaser.com/img/" target="_blank">Lucklaser</a>:</td>
<td><input type="text" name="order_L" id="order_L" size=3 ></td>
<td><input type="button" value="加订单(L)" onclick="addOrder_L()">
</td>	
</tr>

<tr>
<td><a href="http://www.lucklaser.jp/img/" target="_blank">Lucklaser-JP</a>:</td>
<td><input type="text" name="order_LJ" id="order_LJ" size=3 ></td>
<td><input type="button" value="加订单(LJ)" onclick="addOrder_LJ()">
</td>	
</tr>
	
<tr>
<td><a href="http://www.kr.lucklaser.com/img/" target="_blank">Lucklaser-KR</a>:</td>
<td><input type="text" name="order_LK" id="order_LK" size=3 ></td>
<td><input type="button" value="加订单(LK)" onclick="addOrder_LK()">
</td>	
</tr>

<tr>
<td><a href="http://www.civillaser.com/img/" target="_blank">Civillaser</a>:</td>
<td><input type="text" name="order_C" id="order_C"  size=3 ></td>
<td><input type="button" value="加订单(C)" onclick="addOrder_C()">
</td>	
</tr>
<tr>
<td><a href="http://www.jp.civillaser.com/img/" target="_blank">Civillaser-JP</a>:</td>
<td><input type="text" name="order_CJ" id="order_CJ"  size=3 ></td>
<td><input type="button" value="加订单(CJ)" onclick="addOrder_CJ()">
</td>	
</tr>





</table>
</div>

<div id="addOrder" class="leftDiv left2" >
<table>

<tr>
<td><a href="http://www.hiteclaser.com/img/" target="_blank">Hiteclaser</a>:</td>
<td><input type="text" name="order_H" id="order_H" size=3 ></td>
<td><input type="button" value="加订单(H)" onclick="addOrder_H()">	
</td>		
</tr>
<!--
<tr>
<td>Laser-door:</td>
<td><input type="text" name="order_LD" id="order_LD" size=3 ></td>
<td><input type="button" value="加订单(LD)" onclick="addOrder_LD()">	
</td>		
</tr>
-->
	
	
<tr>
<td><a href="http://www.kennbikyou.com/img/" target="_blank">Kennbikyou</a>:</td>
<td><input type="text" name="order_K" id="order_K"  size=3 ></td>
<td><input type="button" value="加订单(K)" onclick="addOrder_K()">
</td>	
</tr>
<tr>
<td><a href="http://www.dmicroscope.com/img/" target="_blank">DMicroscope</a>:</td>
<td><input type="text" name="order_D" id="order_D" size=3 ></td>
<td><input type="button" value="加订单(D)" onclick="addOrder_D()">
</td>	
</tr>
<tr>
<td><a href="http://www.spycamhidden.com/img/" target="_blank">Spycamhidden</a>:</td>
<td><input type="text" name="order_S" id="order_S" size=3 ></td>
<td><input type="button" value="加订单(S)" onclick="addOrder_S()">
</td>	
</tr>

<tr>
<td><a href="http://www.canetalaser.com/img/" target="_blank">Canetalaser</a>:</td>
<td><input type="text" name="order_CA" id="order_CA" size=3 ></td>
<td><input type="button" value="加订单(CA)" onclick="addOrder_CA()">
</td>	
</tr>

</table>
<?php }?>


</div>

<div class="clearBoth">&nbsp;</div>

<div class="grayTable">	
<?php
$topTitle = "<b>";
if($doFlag == "doSearch"){	
	$topTitle =  $topTitle."搜索结果:";
}else{
	$topTitle =  $topTitle."订单列表:";
}
$topTitle = $topTitle."</b>";
$topTitle =  $topTitle."    <a href='/order/orderList.php'>处理中</a>";
$topTitle =  $topTitle."    <a href='javascript:toOrderStatus(200)'>售后中</a>";
$topTitle =  $topTitle."    <a href='javascript:toOrderStatus(10)'>没付款</a>";
$topTitle =  $topTitle."    <a href='javascript:toOrderStatus(20)'>已付款</a>";
$topTitle =  $topTitle."    <a href='javascript:toOrderStatus(30)'>已发货</a>";
$topTitle =  $topTitle."    <a href='javascript:toOrderStatus(40)'>已完成</a>";
$topTitle =  $topTitle."    <a href='javascript:toOrderStatus(100)'>已取消</a>";
$topTitle =  $topTitle."    <a href='javascript:toOrderStatus(300)'>全部售后</a>";
$topTitle =  $topTitle."    <a href='javascript:toOrderStatus(0)'>全部</a>";
$topTitle =  $topTitle."    <a href='orderInput.php'>新增订单</a>";
$topTitle =  $topTitle."    <a href='http://www.aliexpress.com/store/1333902' target='_blank'>   速卖通</a>";


echo $topTitle;
?>


<table >
<thead>
	<tr>
		<th scope="col" width=80>时间|打印</th>
	    <th scope="col" >订单明细</th>		
		<th scope="col" >地址|进展</th>		
		<th scope="col" width=65>状态|售后</th>
		<th scope="col" width=150>操作[1]</th>
		<th scope="col" width=50>操作[2]</th>
	</tr>
</thead>

<tbody>	
<?php
	
	if(empty($result) || $result->RecordCount() < 1){
		echo "<tr><td colspan=6 align='center'>记录为空.</td></tr>";
	}else{
			while (!$result->EOF) {
				//取当前任务的进展记录描述
				$sql = "SELECT * from orderprocess where order_id=".$result->fields['id']." order by modifytime asc";	
				$resultProcess = $db->Execute($sql);
				$currentProcess = $result->fields['customer_name'].",".$result->fields['customer_address']." <br>Post code:".$result->fields['customer_postcode']."   Tel: ".$result->fields['customer_telephone']."<br>--------------------------------------<br>";		
				while (!$resultProcess->EOF) {
					$order_processField = $resultProcess->fields['order_process'];
					if(strlen($order_processField)>100){
						$order_processField = substr($order_processField,0,100)."...";
					}
					$currentProcess = $currentProcess.$resultProcess->fields['modifytime']."&nbsp;&nbsp;".$order_processField."<br>";
					$resultProcess->MoveNext();	
				}
				$products_info = $result->fields['products_info'];	
				$battery_flag_0 = '';
				$battery_flag_1 = '';
				if( $result->fields['battery_flag'] == 1){
					$battery_flag_0 = '';
					$battery_flag_1 = 'selected';
				}else{
					$battery_flag_0 = 'selected';
					$battery_flag_1 = '';
				}

				$deliver_flag_0 = '';
				$deliver_flag_1 = '';
				$deliver_flag_2 = '';
				$deliver_flag_3 = '';
				$deliver_flag_4 = '';
				$deliver_flag_5 = '';
				$deliver_flag_6 = '';
				$deliver_flag_7 = '';
				$deliver_flag_8 = '';
				$deliver_flag_9 = '';
				$deliver_flag_10 = '';
				$deliver_flag_11 = '';
				$deliver_flag_12 = '';
				$deliver_flag_13 = '';
				if( $result->fields['deliver_flag'] == 0){
					$deliver_flag_0 = 'selected';
				}else if( $result->fields['deliver_flag'] == 1){
					$deliver_flag_1 = 'selected';
				}else if( $result->fields['deliver_flag'] == 2){
					$deliver_flag_2 = 'selected';
				}else if( $result->fields['deliver_flag'] == 3){
					$deliver_flag_3 = 'selected';
				}else if( $result->fields['deliver_flag'] == 4){
					$deliver_flag_4 = 'selected';
				}else if( $result->fields['deliver_flag'] == 5){
					$deliver_flag_5 = 'selected';
				}else if( $result->fields['deliver_flag'] == 6){
					$deliver_flag_6 = 'selected';
				}else if( $result->fields['deliver_flag'] == 7){
					$deliver_flag_7 = 'selected';
				}else if( $result->fields['deliver_flag'] == 8){
					$deliver_flag_8 = 'selected';
				}else if( $result->fields['deliver_flag'] == 9){
					$deliver_flag_9 = 'selected';
				}else if( $result->fields['deliver_flag'] == 10){
					$deliver_flag_10 = 'selected';
				}else if( $result->fields['deliver_flag'] == 11){
					$deliver_flag_11 = 'selected';
				}else if( $result->fields['deliver_flag'] == 12){
					$deliver_flag_12 = 'selected';
				}else if( $result->fields['deliver_flag'] == 13){
					$deliver_flag_13 = 'selected';
				}

			
				if( $result->fields['order_site'] == 'lucklaser.jp'){
					$printPageLink = "http://www.".$result->fields['order_site']."/img/invoice.php?oID=".$commonFunction->getOrderNumber($result->fields['order_no'],$result->fields['order_site']);
					$orderDetailLink = "http://www.".$result->fields['order_site']."/img/orders.php?page=1&oID=".$commonFunction->getOrderNumber($result->fields['order_no'],$result->fields['order_site'])."&action=edit";
				}else if($result->fields['order_site'] == 'aliexpress'){
				    $printPageLink = "http://trade.aliexpress.com/order_detail.htm?orderId=".$commonFunction->getOrderNumber($result->fields['order_no'],$result->fields['order_site']);
				}else{
					$printPageLink = "http://www.".$result->fields['order_site'].".com/img/invoice.php?oID=".$commonFunction->getOrderNumber($result->fields['order_no'],$result->fields['order_site']);
					$orderDetailLink = "http://www.".$result->fields['order_site'].".com/img/orders.php?page=1&oID=".$commonFunction->getOrderNumber($result->fields['order_no'],$result->fields['order_site'])."&action=edit";
				}

				$strTR = "<tr >";	
				//turn to detail page: <a href='http://www.".$result->fields['order_site'].".com/img/orders.php?page=1&oID=".substr($result->fields['order_no'],1)."&action=edit' target='_blank'>
				$strTR = $strTR."<td width=70>".$result->fields['modify_time']."<br>[<a href='".$printPageLink."' target='_blank'>".$result->fields['order_no']."</a>]</td>";
				$strTR = $strTR."<td  >".$products_info."<br><a href='".$orderDetailLink."' target='_blank'>Email:".$result->fields['customer_email']."</a></td>";		
				$strTR = $strTR."<td>".$currentProcess."<input type='text' size=30 name='process_".$result->fields['id']."' id='process_".$result->fields['id']."'><input type='button' value='提交' onclick='addProcess(".$result->fields['id'].")'></td>";
				$strTR = $strTR."<td  >".$commonFunction->getOrderStatusName($result->fields['order_status'])."<br>";
				//$strTR = $strTR.$commonFunction->getPaymentName($result->fields['payment_flag']);
				//该客户总订单数
				if($result->fields['sum_orders']>0){
					//$strTR = $strTR."<br>";
					$strTR = $strTR."<a href=\"javascript:emailSearch('".$result->fields['customer_email']."')\">Orders:".$result->fields['sum_orders']."</a>";
				}				
				//售后处理
				if($result->fields['order_status'] == "40"){//已完成的订单 可能有售后服务
					$strTR = $strTR."<br>";
					if($result->fields['customer_service_flag'] == "0"){
						$strTR = $strTR."无售后<br>";
						$strTR = $strTR."<input type='button' value='转售后' onclick='beginCustomerService(".$result->fields['id'].")'>";
					}else if($result->fields['customer_service_flag'] == "1"){
						$strTR = $strTR."售后中...<br>";
						$strTR = $strTR."<input type='button' value='售后完成' onclick='endCustomerService(".$result->fields['id'].")'>";
					}else if($result->fields['customer_service_flag'] == "2"){
						$strTR = $strTR."售后完成<br>";
						$strTR = $strTR."<input type='button' value='再转售后' onclick='beginCustomerService(".$result->fields['id'].")'>";
					}
				}
				//For LuckLaser 1mw Invoice
				if( $result->fields['order_site'] == 'lucklaser'){
					$strTR = $strTR."<br>";
					$printPageLink = "http://www.".$result->fields['order_site'].".com/img/invoice2.php?oID=".$commonFunction->getOrderNumber($result->fields['order_no'],$result->fields['order_site']);
					$strTR = $strTR."<a href='".$printPageLink."' target='_blank'>".$result->fields['order_no']."(1mw)</a>";
					//$strTR = $strTR."<br>";
				}			
				
				$strTR = $strTR."</td>";
				$strTR = $strTR."<td width=95>";
				if($result->fields['order_status'] == "10"){//没付款	
					if( $result->fields['order_site'] == 'hiteclaser'){
						$strTR = $strTR."<input type='button' value='付款邮件' onclick='paymentEmail(".$result->fields['id'].")'>";
						//$strTR = $strTR."<input type='button' value='银行催款' onclick='askPaymentEmail(".$result->fields['id'].")'>";
						/*
						if($result->fields['tracking_flag'] == "0"){
							$strTR = $strTR."<input type='button' value='转入跟单' onclick='doTracking(".$result->fields['id'].")'>";
						}else{
							$strTR = $strTR."<input disabled='disabled' type='button' value='转入跟单' onclick='doTracking(".$result->fields['id'].")'>";
						}						
						$strTR = $strTR."<br>--------------------------<br>";		
						*/
						$strTR = $strTR."<input type='button' value='确认付款' onclick='confirmPaymentEmail(".$result->fields['id'].")'>";
					}else if( $result->fields['order_site'] == 'lucklaser.jp'){
						$strTR = $strTR."<input type='button' value='付款邮件' onclick='paymentEmail(".$result->fields['id'].")'>";
						$strTR = $strTR."<input type='button' value='确认付款' onclick='confirmPaymentEmail(".$result->fields['id'].")'>";
					}else if( $result->fields['order_site'] == 'kr.lucklaser'){
						$strTR = $strTR."<input type='button' value='付款邮件' onclick='paymentEmail(".$result->fields['id'].")'>";
						$strTR = $strTR."<input type='button' value='确认付款' onclick='confirmPaymentEmail(".$result->fields['id'].")'>";
					}else if( $result->fields['order_site'] == 'lucklaser'){
						$strTR = $strTR."<input type='button' value='付款邮件' onclick='paymentEmail(".$result->fields['id'].")'>";
						$strTR = $strTR."<input type='button' value='确认付款' onclick='confirmPaymentEmail(".$result->fields['id'].")'>";
					}else if( $result->fields['order_site'] == 'canetalaser'){
						$strTR = $strTR."<input type='button' value='付款邮件' onclick='paymentEmail(".$result->fields['id'].")'>";
						$strTR = $strTR."<input type='button' value='确认付款' onclick='confirmPaymentEmail(".$result->fields['id'].")'>";
					}
					
				}else if($result->fields['order_status'] == "20"){//已付款	
					$strTR = $strTR."<input type='button' value='打印发货' onclick=\"sendPackage(".$result->fields['id'].",'".$result->fields['order_site']."','".$printPageLink."')\">";
				}else if($result->fields['order_status'] == "30"){//已发货(等快递单)
					if($result->fields['deliver_flag'] == 3){
						$strTR = $strTR."<input disabled='disabled' type='button' value='快递已取消' onclick='sendTrackingNumber(".$result->fields['id'].",".$result->fields['deliver_flag'].")'>";
					}else{
						if($result->fields['tracking_number'] == ""){//还没填快递单
							$strTR = $strTR."<input disabled='disabled' type='button' value='发快递单' onclick='sendTrackingNumber(".$result->fields['id'].",".$result->fields['deliver_flag'].")'>";
						}else{
							$strTR = $strTR."<input type='button' value='发快递单' onclick='sendTrackingNumber(".$result->fields['id'].",".$result->fields['deliver_flag'].")'>";
						}
					}										
				}
				$strTR = $strTR."<br>--------------------------<br>";
				$strTR = $strTR."<select name='battery_flag_".$result->fields['id']."' id='battery_flag_".$result->fields['id']."'><option value='0' ".$battery_flag_0." >无电池</option><option value='1' ".$battery_flag_1.">带电池</option></select>";
				$strTR = $strTR."<input type='button' value='Battery' onclick='updateBatteryFlag(".$result->fields['id'].")'>";				
				$strTR = $strTR."<br>";
				$strTR = $strTR."<input type='text' size=7 name='product_description_".$result->fields['id']."' id='product_description_".$result->fields['id']."' value='".$result->fields['product_description']."'>";
				$strTR = $strTR."<input type='button' value='Product' onclick='updateProductDescription(".$result->fields['id'].")'>";
				//bof:快递状态-----注意:一行改3个数字--------------------------------------
			    $strTR = $strTR."<br>"; 
				$strTR = $strTR."<select name='deliver_flag_".$result->fields['id']."' id='deliver_flag_".$result->fields['id']."'>";				
				$strTR = $strTR."<option value='0' ".$deliver_flag_0." >".$commonFunction->getDeliverName(0)."</option>";
				//eub
				$strTR = $strTR."<option value='4' ".$deliver_flag_4." >".$commonFunction->getDeliverName(4)."</option>";
				$strTR = $strTR."<option value='5' ".$deliver_flag_5." >".$commonFunction->getDeliverName(5)."</option>";
				$strTR = $strTR."<option value='6' ".$deliver_flag_6." >".$commonFunction->getDeliverName(6)."</option>";
				//阿运
				$strTR = $strTR."<option value='11' ".$deliver_flag_11." >".$commonFunction->getDeliverName(11)."</option>";
				$strTR = $strTR."<option value='12' ".$deliver_flag_12." >".$commonFunction->getDeliverName(12)."</option>";
				$strTR = $strTR."<option value='13' ".$deliver_flag_13." >".$commonFunction->getDeliverName(13)."</option>";
				//易运
				$strTR = $strTR."<option value='7' ".$deliver_flag_7." >".$commonFunction->getDeliverName(7)."</option>";
				$strTR = $strTR."<option value='8' ".$deliver_flag_8." >".$commonFunction->getDeliverName(8)."</option>";
				$strTR = $strTR."<option value='9' ".$deliver_flag_9." >".$commonFunction->getDeliverName(9)."</option>";
				//飞翔
				$strTR = $strTR."<option value='1' ".$deliver_flag_1." >".$commonFunction->getDeliverName(1)."</option>";
				$strTR = $strTR."<option value='10' ".$deliver_flag_10." >".$commonFunction->getDeliverName(10)."</option>";
				$strTR = $strTR."<option value='2' ".$deliver_flag_2." >".$commonFunction->getDeliverName(2)."</option>";
				//取消		
				$strTR = $strTR."<option value='3' ".$deliver_flag_3." >".$commonFunction->getDeliverName(3)."</option>";
				$strTR = $strTR."</select>";
				if($result->fields['order_status'] == "30" && $result->fields['tracking_number'] == ""){//已发货,代理还没填单号,此时可选：是否走e邮宝
					$strTR = $strTR."<input type='button' value='Deliver' onclick='updateDeliverFlag(".$result->fields['id'].")'>";	
				}else{
					$strTR = $strTR."<input type='button' disabled='disabled' value='Deliver' onclick='updateDeliverFlag(".$result->fields['id'].")'>";
				}
				
				//eof:快递状态-------------------------------------------
				$strTR = $strTR."</td>";
				$strTR = $strTR."<td>";
				if($result->fields['order_status'] == "30"){//打印了发货单后
					if($result->fields['deliver_flag'] == 0){//货到了
						$strTR = $strTR."<input type='button' value='货到' onclick='doInStock(".$result->fields['id'].")'>";				
					}else{//缺货登记
						$strTR = $strTR."<input type='button' value='缺货' onclick='doOutStock(".$result->fields['id'].")'>";				
					}
				}				
				$strTR = $strTR."<input type='button' value='编辑' onclick='doEdit(".$result->fields['id'].")'>";				
				//$strTR = $strTR."<input type='button' value='邮件' onclick=\"sendEmail('".$result->fields['customer_email']."','".$commonFunction->getEmailSubject($result->fields['order_no'],$result->fields['order_site'],$current_system)."')\">";
				$strTR = $strTR."<input type='button' value='邮件' onclick='emptyEmail(".$result->fields['id'].")' >";
				$strTR = $strTR."<input type='button' value='取消' onclick=\"doCancel('".$result->fields['id']."','".$result->fields['order_no']."')\">";
				$strTR = $strTR."</td>";
				$strTR = $strTR."</tr>";
				echo $strTR;
				$result->MoveNext();	
			}
	}

?>

</tbody>
					
</table>	
<br>
<!--Page 分页 -->
<div id="page"><?php echo $page->show(2);?></div>


</div>



</div><!--end container -->

<input type="hidden" name="doFlag" id="doFlag" value="<?php echo $doFlag; ?>">
<input type="hidden" name="orderId" id="orderId" >
<input type="hidden" name="orderSite" id="orderSite" >
<input type="hidden" name="nowPage" id="nowPage" value="<?php echo $nowPage; ?>">
<input type="hidden" name="currentOrderStatus" id="currentOrderStatus" value="<?php echo $currentOrderStatus; ?>">
<input type="hidden" name="deliverFlag" id="deliverFlag" value="">
</form>

<form name="addOrderForm" action="../order/addOrder.php" method="post">
<input type="hidden" name="orderId_addOrderForm" id="orderId_addOrderForm" >
<input type="hidden" name="doFlag_addOrderForm" id="doFlag_addOrderForm" >
</form>

</body>




</html>

<script>

<?php
$doFlag = $_POST["doFlag"];
$sendEmailFlag = $_POST["sendEmailFlag"];
$commonFunction = new Common_Function();


if($doFlag == "addProcess"){

	$orderId = $_POST["orderId"];
	echo "$('#process_".$orderId."').focus(); "; 

	//打开邮件内容页面
	if($sendEmailFlag == 'paymentEmail'){
		$emailBody = "window.open ('emailContent.php?id=".$orderId."&sendEmailFlag=paymentEmail"."','_blank','height=600,width=800,top=10,left=10,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no')";
		echo  $emailBody;	
	}else if($sendEmailFlag == 'askPaymentEmail'){
		$emailBody = "window.open ('emailContent.php?id=".$orderId."&sendEmailFlag=askPaymentEmail','_blank','height=600,width=800,top=10,left=10,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no')";
		echo  $emailBody;
	}else if($sendEmailFlag == 'confirmPaymentEmail'){
		$emailBody = "window.open ('emailContent.php?id=".$orderId."&sendEmailFlag=confirmPaymentEmail"."','_blank','height=600,width=800,top=10,left=10,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no')";
		echo  $emailBody;
	}else if($sendEmailFlag == 'sendTrackingNumber'){
		$emailBody = "window.open ('emailContent.php?id=".$orderId."&sendEmailFlag=sendTrackingNumber','_blank','height=600,width=800,top=10,left=10,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no')";
		echo  $emailBody;
	}else if($sendEmailFlag == 'emptyEmail'){
		$emailBody = "window.open ('emailContent.php?id=".$orderId."&sendEmailFlag=emptyEmail','_blank','height=600,width=800,top=10,left=10,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no')";
		echo  $emailBody;
	}

}
?>





/************订单进展**************************/
function addProcess(id){
	document.getElementById('doFlag').value = "addProcess";
	document.getElementById('orderId').value = id;
	var processStr = document.getElementById('process_'+id).value;
	if(processStr == ""){
		alert("进展内容不能为空")
		document.getElementById('process_'+id).focus();  
		return;
	}
	document.listForm.submit();
}


/************编辑订单**************************/
function doEdit(id){
	 window.location.href="orderInput.php?id="+id; 
}

/************更改电池状态**************************/
function updateBatteryFlag(id){
	document.getElementById('doFlag').value = "updateBatteryFlag";
	document.getElementById('orderId').value = id;
	document.listForm.submit();
}



/************更改快递状态**************************/
function updateDeliverFlag(id){
	document.getElementById('doFlag').value = "updateDeliverFlag";
	document.getElementById('orderId').value = id;
	document.listForm.submit();
}

/************更改产品描述**************************/
function updateProductDescription(id){
	document.getElementById('doFlag').value = "updateProductDescription";
	document.getElementById('orderId').value = id;
	document.listForm.submit();
}

/************新加订单 Hiteclaser**************************/
function  addOrder_H(){
	var orderId = $("#order_H").val();	
	if(orderId==""){
		alert("ID不能为空");
		$("#order_H").focus();  
		return;
	}else{
		if(isNaN(orderId)){
			alert("订单编号只能是数字.");
		    $("#order_H").focus(); 
		    return false;
		}

		document.getElementById('doFlag_addOrderForm').value = "order_H";
		document.getElementById('orderId_addOrderForm').value = $("#order_H").val();	
		document.addOrderForm.submit();
	}
}

/************新加订单 Lucklaser.jp**************************/
function  addOrder_LJ(){
	var orderId = $("#order_LJ").val();	
	if(orderId==""){
		alert("ID不能为空");
		$("#order_LJ").focus();  
		return;
	}else{
		if(isNaN(orderId)){
			alert("订单编号只能是数字.");
		    $("#order_LJ").focus(); 
		    return false;
		}

		document.getElementById('doFlag_addOrderForm').value = "order_LJ";
		document.getElementById('orderId_addOrderForm').value = $("#order_LJ").val();	
		document.addOrderForm.submit();
	}
}
	
/************新加订单 Lucklaser-kr**************************/
function  addOrder_LK(){
	var orderId = $("#order_LK").val();	
	if(orderId==""){
		alert("ID不能为空");
		$("#order_LK").focus();  
		return;
	}else{
		if(isNaN(orderId)){
			alert("订单编号只能是数字.");
		    $("#order_LK").focus(); 
		    return false;
		}

		document.getElementById('doFlag_addOrderForm').value = "order_LK";
		document.getElementById('orderId_addOrderForm').value = $("#order_LK").val();	
		document.addOrderForm.submit();
	}
}


/************新加订单 Lucklaser**************************/
function  addOrder_L(){
	var orderId = $("#order_L").val();	
	if(orderId==""){
		alert("ID不能为空");
		$("#order_L").focus();  
		return;
	}else{
		if(isNaN(orderId)){
			alert("订单编号只能是数字.");
		    $("#order_L").focus(); 
		    return false;
		}
		document.getElementById('doFlag_addOrderForm').value = "order_L";
		document.getElementById('orderId_addOrderForm').value = $("#order_L").val();	
		document.addOrderForm.submit();
	}
}


/************新加订单 Civillaser**************************/
function  addOrder_C(){
	var orderId = $("#order_C").val();	
	if(orderId==""){
		alert("ID不能为空");
		$("#order_C").focus();  
		return;
	}else{
		if(isNaN(orderId)){
			alert("订单编号只能是数字.");
		    $("#order_C").focus(); 
		    return false;
		}
		document.getElementById('doFlag_addOrderForm').value = "order_C";
		document.getElementById('orderId_addOrderForm').value = $("#order_C").val();	
		document.addOrderForm.submit();
	}
}


/************新加订单 Civillaser-jp**************************/
function  addOrder_CJ(){
	var orderId = $("#order_CJ").val();	
	if(orderId==""){
		alert("ID不能为空");
		$("#order_CJ").focus();  
		return;
	}else{
		if(isNaN(orderId)){
			alert("订单编号只能是数字.");
		    $("#order_CJ").focus(); 
		    return false;
		}
		document.getElementById('doFlag_addOrderForm').value = "order_CJ";
		document.getElementById('orderId_addOrderForm').value = $("#order_CJ").val();	
		document.addOrderForm.submit();
	}
}


/************新加订单 laser-door**************************/
function  addOrder_LD(){
	var orderId = $("#order_LD").val();	
	if(orderId==""){
		alert("ID不能为空");
		$("#order_LD").focus();  
		return;
	}else{
		if(isNaN(orderId)){
			alert("订单编号只能是数字.");
		    $("#order_LD").focus(); 
		    return false;
		}
		document.getElementById('doFlag_addOrderForm').value = "order_LD";
		document.getElementById('orderId_addOrderForm').value = $("#order_LD").val();	
		document.addOrderForm.submit();
	}
}


/************新加订单 Kennbikyou**************************/
function  addOrder_K(){
	var orderId = $("#order_K").val();	
	if(orderId==""){
		alert("ID不能为空");
		$("#order_K").focus();  
		return;
	}else{
		if(isNaN(orderId)){
			alert("订单编号只能是数字.");
		    $("#order_K").focus(); 
		    return false;
		}
		document.getElementById('doFlag_addOrderForm').value = "order_K";
		document.getElementById('orderId_addOrderForm').value = $("#order_K").val();	
		document.addOrderForm.submit();
	}
}


/************新加订单 DMicroscope**************************/
function  addOrder_D(){
	var orderId = $("#order_D").val();	
	if(orderId==""){
		alert("ID不能为空");
		$("#order_D").focus();  
		return;
	}else{
		if(isNaN(orderId)){
			alert("订单编号只能是数字.");
		    $("#order_D").focus(); 
		    return false;
		}
		document.getElementById('doFlag_addOrderForm').value = "order_D";
		document.getElementById('orderId_addOrderForm').value = $("#order_D").val();	
		document.addOrderForm.submit();
	}
}


/************新加订单 Spycamhidden**************************/
function  addOrder_S(){
	var orderId = $("#order_S").val();	
	if(orderId==""){
		alert("ID不能为空");
		$("#order_S").focus();  
		return;
	}else{
		if(isNaN(orderId)){
			alert("订单编号只能是数字.");
		    $("#order_S").focus(); 
		    return false;
		}
		document.getElementById('doFlag_addOrderForm').value = "order_S";
		document.getElementById('orderId_addOrderForm').value = $("#order_S").val();	
		document.addOrderForm.submit();
	}
}



/************新加订单 Canetalaser**************************/
function  addOrder_CA(){
	var orderId = $("#order_CA").val();	
	if(orderId==""){
		alert("ID不能为空");
		$("#order_CA").focus();  
		return;
	}else{
		if(isNaN(orderId)){
			alert("订单编号只能是数字.");
		    $("#order_CA").focus(); 
		    return false;
		}
		document.getElementById('doFlag_addOrderForm').value = "order_CA";
		document.getElementById('orderId_addOrderForm').value = $("#order_CA").val();	
		document.addOrderForm.submit();
	}
}


/************翻页跳转**************************/
function toList(listFlag){
	document.getElementById('nowPage').value = 1;//第一页
	document.getElementById('doFlag').value = "toList";
	document.getElementById('listFlag').value = listFlag;
	document.listForm.submit();
}


function goToPage(nowPage){
	var doFlag = $("#doFlag").val();
	if(doFlag == "doSearch"){
		document.getElementById('doFlag').value = 'doSearch';
	}else{
		document.getElementById('doFlag').value = 'toList';
	}	
	document.getElementById('nowPage').value = nowPage;
	document.listForm.submit();
}

/************发邮件:mailto**************************/
function sendEmail(customer_email,subject){
	window.location.href="mailto:"+customer_email+"?subject="+subject;
}


/************发邮件:内容:付款方式;(Only for Hiteclaser/Lucklaser)**************************/
function paymentEmail(id,orderSite){
	document.getElementById('doFlag').value = "paymentEmail";
	document.getElementById('orderId').value = id;
	document.listForm.submit();
}




/************发邮件:内容:催付款;(Only for Hiteclaser)**************************/
function askPaymentEmail(id){
	document.getElementById('doFlag').value = "askPaymentEmail";
	document.getElementById('orderId').value = id;
	document.listForm.submit();
}

/************发邮件:内容:确认付款;(Only for Hiteclaser/Lucklaser)**************************/
function confirmPaymentEmail(id,orderSite){
	document.getElementById('doFlag').value = "confirmPaymentEmail";
	document.getElementById('orderId').value = id;
	document.listForm.submit();
}

/************状态更新:已发货**************************/
function sendPackage(id,orderSite,printPageLink){	
	window.open(printPageLink,'_blank','height=800,width=1000,top=10,left=10,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');

	document.getElementById('doFlag').value = "sendPackage";
	document.getElementById('orderId').value = id;
	document.getElementById('orderSite').value = orderSite;
	document.listForm.submit();	
	/*
	//打开快递单页面->补充快递单页面内容->按"确定"->订单状态改成"已发货", 快递单表插入1记录;
	var url = "sendPackage.php?id="+id;
	window.open(url,'_blank','height=600,width=800,top=10,left=10,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
	*/
}

/************状态更新:取消订单**************************/
function doCancel(id,order_no){
	if(confirm("确认要取消 "+order_no+" ?")){
		document.getElementById('doFlag').value = "doCancel";
		document.getElementById('orderId').value = id;
		document.listForm.submit();
	}	
}

/************搜索**************************/
function doSearch(){
	document.getElementById('doFlag').value = "doSearch";	
	document.listForm.submit();
}

function emailSearch(email){
	document.getElementById('search-value').value = email;
	doSearch();
}


/************转入跟单**************************/
function doTracking(id){
	document.getElementById('doFlag').value = "doTracking";
	document.getElementById('orderId').value = id;
	document.listForm.submit();
}

/************发快递单给客户**************************/
function sendTrackingNumber(id,deliverFlag){
	document.getElementById('doFlag').value = "sendTrackingNumber";
	document.getElementById('orderId').value = id;
	document.getElementById('deliverFlag').value = deliverFlag;	
	document.listForm.submit();
}


/************空邮件**************************/
function emptyEmail(id){
	document.getElementById('doFlag').value = "emptyEmail";
	document.getElementById('orderId').value = id;
	document.listForm.submit();
}


/************转到某个状态列表**************************/
function toOrderStatus(orderStatus){
	document.getElementById('doFlag').value = "toOrderStatus";
	document.getElementById('currentOrderStatus').value = orderStatus;	
	document.listForm.submit();
}

/************快递状态修改：货到了->需要快递**************************/
function doInStock(id){
	document.getElementById('doFlag').value = "doInStock";
	document.getElementById('orderId').value = id;
	document.listForm.submit();
}


/************快递状态修改：缺货登记->不需要快递**************************/
function doOutStock(id){
	document.getElementById('doFlag').value = "doOutStock";
	document.getElementById('orderId').value = id;
	document.listForm.submit();
}

/************转售后**************************/
function beginCustomerService(id){
	document.getElementById('doFlag').value = "beginCustomerService";
	document.getElementById('orderId').value = id;
	document.listForm.submit();
}

/************售后完成**************************/
function endCustomerService(id){
	document.getElementById('doFlag').value = "endCustomerService";
	document.getElementById('orderId').value = id;
	document.listForm.submit();
}
</script>

